﻿using System.Globalization;
using System.Windows.Data;

namespace XYAC.Framework.MonitorTireMaterialOnline.Converters
{
    public class LocalSyncStateConverter : IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is int val)
            {
                return val switch
                {
                    1 => "检测完毕",
                    -1 => "检测中",
                    _ => "准备",
                };
            }
            else
            {
                return "";
            }
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is string str)
            {
                return str switch
                {
                    "检测完毕" => 1,
                    "检测中" => -1,
                    _ => 0,  // 对应 "准备" 状态
                };
            }
            throw new InvalidOperationException("无法转换回源对象");
        }
    }
}
